const express = require('express')

const userHandler = require('../router_handle/articles')
const router = express.Router()
const path = require('path')

const expressJoi = require('@escook/express-joi')
const { articles_schema } = require('../schema/articles')
const { get_articles_schema } = require('../schema/articles')
const { update_article_schema } = require('../schema/articles')
const { delete_article_schema } = require('../schema/articles')
const multer = require('multer')
const upload = multer({ dest: path.join(__dirname, '../uploads') })

//发布文章
router.post("/article/add", upload.single('cover_img'), expressJoi(articles_schema),
    userHandler.addArticles)

//查看文章列表
router.get('/article/list', userHandler.getList)

//删除文章
router.get('/article/delete/:id', expressJoi(get_articles_schema), userHandler.deleteArticle)

////根据 Id 获取文章信息
router.get('/article/articlesinfo/:id', expressJoi(get_articles_schema), userHandler.getArticles)

router.post('/article/updateArticlesinfo', expressJoi(update_article_schema), userHandler.updateArtices)


// //文章搜索
// router.get('/')


module.exports = router